/*
 * GsonExampleToJSON.java
 * 
 * Created on 09-01-2012
 * 
 * Copyright (C) 2012 Tomas Travnicek, All rights reserved.
 */
package cz.tt.wunderground;

import cz.tt.wunderground.connector.WundergroundConnector;
import cz.tt.wunderground.data.response.Result;
import cz.tt.wunderground.htmlgenerator.WundergroundHtmlGenerator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * 
 * http://api.wunderground.com/api/7ae390ca98247094/astronomy/q/liberec.json
 * http://api.wunderground.com/api/7ae390ca98247094/conditions/forecast/astronomy/lang:CZ/q/CZ/liberec.json
 * 
 * @author Tomas Travnicek <travnicek.tomas at gmail.com>
 * @version $Id: GsonExampleToJSON.java 09-01-2012 15:44:29 ttravnicek
 */
public class WunderMain {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Properties prop = WundergroundHtmlGenerator.load("config.properties");
            WundergroundConnector wunder = new WundergroundConnector(prop);
            
            //wunder.getAutocompleteDataFromWunder();
            //wunder.getAutocompleteHurricaneDataFromWunder();
            
            wunder.getDataFromWunder();
            List<Result> results = wunder.getResponse().getResults();
            if (results != null) {
                Result firstResult = results.get(0);
                wunder.setZmwLocation(firstResult.getZmw());
                wunder.getDataFromWunder();
            }
            
            WundergroundHtmlGenerator.writeToHtmlFile(wunder.getEnvelope(), prop.getProperty("outputHtmlPath"), prop.getProperty("templatePath"));
            
            System.out.println(wunder.getMoonPhase().getCurrent_time().getHour() + ":" + wunder.getMoonPhase().getCurrent_time().getMinute());
        } catch (Exception ex) {
            Logger.getLogger(WunderMain.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
